import post from './index'
import { Toast } from 'antd-mobile'

export let get_request = async (that, params, message, moduleName, pathName) => {
    let resData;
    try {
        console.log(params, message + '请求头')
        resData = await post[moduleName][pathName](params);
        
        if (resData.status !== 200) return Toast.show({  icon: 'fail', content: resData.statusText || '请求错误' })
        
        if (resData.data && resData.data.message !== '成功'){  return resData.data.message}

        console.log(resData.data.data, message)
        return resData.data.data
    } catch (error) {
        Toast.show({  icon: 'fail', content: '请求失败' })
        console.log(error)
    }
    return resData;
}